<?php
namespace app\index\controller;
use app\Request;
use think\facade\Db;
use think\facade\View;


class Pp{
    public function pp()
    {

//        ===============搜索
        $pp = input('keywords');
        $where=[];
        $wheree=[];
        if(isset($pp) && $pp <> ""){
            $where=[['brand_name','like',"%{$pp}%"]];
        };
        View::assign('pp',$pp);

//        ================推荐
        $post=\think\facade\Request::post();
        if(isset($post['tj']) && $post['tj'] <> ""){$where=[['recommended','=',"{$post['tj']}"]];};

//      ==================显示
        if(isset($post['xs']) && count($post['xs'])==1){$where=[['if_show','in',$post['xs']]];};

//        ================图片
        echo '<pre>';
        print_r($post);
        echo '</pre>';
        if(isset($post['tu']) && $post['tu'][0]==1){$wheree=[['brand_logo','<>','']];};
        if(isset($post['tu']) && $post['tu'][0]==2){
            $wheree[]=['brand_logo','=',`null`];
            $wheree[]=['brand_logo','=',''];
        };
        if(isset($post['tu']) && count($post['tu'])==2){$wheree=[];};


        View::assign($post);

        $sql=Db::name('brand')
            ->where($where)
            ->where(function ($q) use($wheree){
            $q->whereOr($wheree);
        })->order('brand_id')->select();
        View::assign('sql',$sql);
        return View();
    }
}